home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ian & Stuart's Australian Mac 1993 September
/
September 93.iso
/
Archives
/
Utilities
/
Text
/
TextMaster 1.4
/
tm14.shar
< prev
next >
Wrap
Text File
|
1991-05-10
|
24KB
|
660 lines
TextMaster -- Version 1.4
By: Donald Burr
INTERNET: dburr@ocf.berkeley.edu, 72540.3071@compuserve.COM
Compu$erve: 72540,3071 America Online: DonaldBurr
This is version 1.4 of TextMaster, a UNIX- and Macintosh-end program to
convert text file formats between UNIX and Macintosh.
This is a MAJOR bug fix release. It fixes a bug in the Macintosh version
which will not correctly convert from Macintosh -> UNIX. Other minor cos-
metic changes and such have been made to both parts of the program,
however.
TextMaster will convert between UNIX newlines and Macintosh end-of-line
characters. Direction of conversion (UNIX -> Mac, or Mac -> UNIX) can be
specified at the command line, and thus files can be converted in any
direction.
This is useful if your UNIX -> Mac downloads, or uploads, of text files
are failing miserably. White Knight has a tendency to do this, and other
comm programs may as well.
Please send all comments, bug reports, feature requests, etc. to the
Internet address listed above.
This software is being donated to the public domain. Permission is hereby
granted to freely copy and distribute this source code, as long as no fees
are charged for such duplication. Permission is also granted to modify
this source code at will, providing that you insert a notice in the dist-
ribution that this source is NOT the original TextMaster source, and that you
not remove my name from the program and accompanying documentation.
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# README
# MANIFEST
# BUGS
# TODO
# Makefile
# tm.c
# tm.h
# convert.c
# tm.1
# Wrapped by root@deutsch on Fri May 10 01:31:26 1991
export PATH; PATH=/bin:$PATH
echo shar: extracting "'README'" '(4521 characters)'
if test -f 'README'
then
echo shar: will not over-write existing file "'README'"
else
cat << \SHAR_EOF > 'README'
TextMaster -- Version 1.4
By: Donald Burr
INTERNET: dburr@ocf.berkeley.edu, 72540.3071@compuserve.COM
Compu$erve: 72540,3071 America Online: DonaldBurr
This is version 1.4 of TextMaster, a UNIX- and Macintosh-end program to
convert text file formats between UNIX and Macintosh.
This release fixes a MAJOR bug in the Macintosh end. The Mac end will now
correctly convert files from Mac -> UNIX.
TextMaster will convert between UNIX newlines and Macintosh end-of-line
characters. The direction of conversion can be specified at the command
line, and thus files can be converted in any direction.
This is useful if your UNIX -> Mac downloads, or uploads, of text files
are failing miserably. White Knight has a tendency to do this, and other
comm programs may as well.
Please send all comments, bug reports, feature requests, etc. to the
Internet address listed above.
This software is being donated to the public domain. Permission is hereby
granted to freely copy and distribute this source code, as long as no fees
are charged for such duplication. Permission is also granted to modify
this source code at will, providing that you insert a notice in the dist-
ribution that this source is NOT the original TextMaster source, and that you
not remove my name from the program and accompanying documentation.
WHAT IS TEXTMASTER?
It is a utility I hacked together to convert between Macintosh end-
of line characters, and UNIX newlines. I downloaded a mess of text files
one day to my Mac, and found they all came out on one line, with weird char-
acters (represented by "boxes") between where "line breaks" should have been.
Since I really couldn't download those files again, I decided to write a
utility to help me convert and salvage them. Thus was born TextMaster, which
was released (up to version 1.3) as "Macify". Since then, I have found out
that there already is a product called Macify, so in this release, I change
the name to TextMaster. Nuff said.
HOW TO COMPILE IT
First, edit the Makefile. It is fully commented, and should be
self-explanatory.
Next, edit "tm.h". The first segment of this file is to set up what
#include file your system uses for string functions. On SysV, this typically
is <string.h>. However, if you're on a BSD system, this typically is
<strings.h>. If you are on MSDOS, Mac, or some other platform, find out
what #include file your string routines are in, or if there is NO include
for string functions, and edit this accordingly.
Next, check over the definitions for characters for EOL's. These
should remain constant, but just check them over just in case.
Now, simply typing "make" will compile an executable in the current
directory. Test it out some, and if it seems to work, type "make install",
and a copy of the binary and man pages will be placed in the appropriate
places.
USAGE
The man page explains how to use the program, as does the screen
that appears when invoking TextMaster without any arguments. There isn't
any space here in the README to fully describe it.
LAST WORDS
Certainly hope you enjoy this program. It took a bit of work, es-
pecially the Mac portion of it, but I find it useful.
I am charging no shareware fee or anything for this. It's free.
Take it, use it in good health. Modify it at will. However, when modify-
ing the program, leave the version number intact; just tack on your own
version number after mine. Example, if the version # of TextMaster is 1.4,
and your name is Bill Smith, and this is the second revision to my code
you have done, change the version number to something like "1.4/BS-2",
the "BS" symbolizing this is Bill Smith's version, and the '2' signifying
this is Bill Smith's 2nd version. Now you can redistribute the program;
this way, we can keep track of which is the "genuine" version, and so
forth.
Two things I ask if you redistribute this work are, (a) my credit
(name, copyright, etc.) MUST remain in all documentation and program
displays, and (b) You not charge for distribution or shareware fees.
Please email me with all bug reports, suggestions for changes, and
so on. Better yet, if you have a suggestion for a change or a bug fix or
whatnot, and you can program in C, make the patch yourself, and mail me a
copy of the resultant source code. If it's good, and I like it, I'll be
sure to include it in my next version, with your name in the credits! My
email addresses can be found at the beginning of this document.
SHAR_EOF
if test 4521 -ne "`wc -c < 'README'`"
then
echo shar: error transmitting "'README'" '(should have been 4521 characters)'
fi
chmod +x 'README'
fi # end of overwriting check
echo shar: extracting "'MANIFEST'" '(895 characters)'
if test -f 'MANIFEST'
then
echo shar: will not over-write existing file "'MANIFEST'"
else
cat << \SHAR_EOF > 'MANIFEST'
*************************************************************************
** **
** Manifest of Files for TextMaster **
** **
*************************************************************************
FILE NAME WHAT IT IS
========= ==========
BUGS File describing current bugs & incompatibilites of this prog.
MANIFEST This file.
Makefile File to be used with "make" to compile this program
README Read this file for important release information
TODO Things I'd like to do with this program in the future
convert.c TextMaster file conversion routine
tm.1 TextMaster man page (nroff -man format)
tm.c TextMaster main routine
tm.h TextMaster standard define's
tm.hqx TextMaster Macintosh version (StuffIt, then BinHex)
SHAR_EOF
if test 895 -ne "`wc -c < 'MANIFEST'`"
then
echo shar: error transmitting "'MANIFEST'" '(should have been 895 characters)'
fi
chmod +x 'MANIFEST'
fi # end of overwriting check
echo shar: extracting "'BUGS'" '(2075 characters)'
if test -f 'BUGS'
then
echo shar: will not over-write existing file "'BUGS'"
else
cat << \SHAR_EOF > 'BUGS'
*************************************************************************
** **
** Known Bugs/Incompatibilities with TextMaster **
** **
*************************************************************************
(UNIX Version)
+ TextMaster will probably barf on non-text input/files (e.g. type special
files, binaries, etc.)
+ TextMaster currently does not support wildcard extension. A future version
will incorporate this, as well as allowing you to specify only the
source filename, in which case the destination filename will auto-
matically be named [sourcefile].conv.
+ If you give it a filename that does not exist, for input, TextMaster will
most likely either complain or barf.
(Macintosh Version)
+ TextMaster will barf if the input file is non-text (i.e. application,
binary, etc.)
+ TextMaster NOW CORRECTLY CONVERTS files from Mac -> UNIX. HOWEVER,
it saves the converted output file as filetype "????", creator "????".
Thus, most wordprocessors cannot open it directly. However, in many
cases, pressing and holding Option (or, in the case of Microsoft Word,
pressing and holding Shift) while selecting "Open" will let you open
these files. If anyone can fix this so it'll save as TEXT, please
drop me an E-Mail notice telling what the problem is, and how to
resolve it! Thanks!
+ TextMaster will overwrite the output file (file.out), if it exists
already.
+ TextMaster curently doesn't support background events, and other such
Mac-isms. This will perhaps be integrated in a future version.
+ The code for TextMaster is very messy.
+ TextMaster does almost NO error-checking. Thus, if you do something to it
that it doesn't expect, it'll most likely bomb.
+ TextMaster currently saves its output files as type "TEXT" but creator
"????". A future upgrade will allow you to specify the file type (MSWD,
MACA, ttxt, etc.)
SHAR_EOF
if test 2075 -ne "`wc -c < 'BUGS'`"
then
echo shar: error transmitting "'BUGS'" '(should have been 2075 characters)'
fi
chmod +x 'BUGS'
fi # end of overwriting check
echo shar: extracting "'TODO'" '(2407 characters)'
if test -f 'TODO'
then
echo shar: will not over-write existing file "'TODO'"
else
cat << \SHAR_EOF > 'TODO'
************************************************************************
** **
** Things I would Like to Do with this Program **
** **
************************************************************************
If you have any ideas as to how I can accomplish any of these, please
let me know , through E-Mail. (dburr@ocf.berkeley.edu)
(UNIX Version)
1. Getting TextMaster to work with multiple files, processing each indi-
vidually. (Using wildcard expansion)
2. Getting TextMaster to be able to accept only one filename, the "input"
file. TextMaster will generate its own name for the outfile, by
tacking on ".out" or ".conv" or something equally as meaningful
to the name of the input file. ("text" becomes "text.out") This
will be needed to complete #1, or else you would have to have the
user prompted for a destination filename each time a new file is
processed, which is messy.
3. Possible interface to XMODEM, ZMODEM, or some other protocol, so that
when you convert files, they automatically get (up)/(down)loaded.
4. Adding IBM file format support.
5. I don't know! If you can think of something I can do to improve this,
let me know through email!
(Macintosh Version)
1. Cleaning up the code some, removing/fixing inconsistencies, duplicates,
functions not needed, etc.
2. Allowing you to choose a filename for the output file, instead of
tacking on the ".out" to the file you open, like it does now.
3. Adding a better user interface, with a possible Progress dialog box,
and a dialog that displays when you finish, as well as a dialog that
pops up if errors occur.
4. Incorporate error checking in the Mac version.
5. Making the file type/creator settable (i.e. if you want files to
come out with filetype "MSWD" for you Microsoft freaks). Also, fixing
the Mac -> UNIX transfer so that it will save as filetype "TEXT";
see BUGS for more details.
6. Adding IBM file format support in both Mac and UNIX ends.
7. Incorporating Batch Processing into TextMaster. This way, you could
convert a whole folder of files all at the same time.
8. I don't know! If you can think of something I can do to improve this,
let me know through email!
SHAR_EOF
if test 2407 -ne "`wc -c < 'TODO'`"
then
echo shar: error transmitting "'TODO'" '(should have been 2407 characters)'
fi
chmod +x 'TODO'
fi # end of overwriting check
echo shar: extracting "'Makefile'" '(2304 characters)'
if test -f 'Makefile'
then
echo shar: will not over-write existing file "'Makefile'"
else
cat << \SHAR_EOF > 'Makefile'
###########################################################################
## ##
## Makefile for TextMaster ##
## ##
###########################################################################
# Values here should be changed to whatever's appropriate for your system
# Change this to the C compiler you use. Most systems will handle 'cc'
# fine, since I didn't write this in ANSI C or anything special. On some
# systems, GCC may provide better and smaller output, so try that instead.
CC=cc
# Replace this with any compile-time flags you wish to set.
CFLAGS=-O
# This is where the binaries (BINDIR) and man pages (MANDIR) will be installed
# if you type 'make install'. Change this to whatever's appropriate.
BINDIR=/usr/local
MANDIR=/usr/man/local/man1
# This is the program to be used to install the binaries and man pages.
# I use 'cp' because it's simple, and some versions of 'install' (the system
# built-in installation program) don't work right.
INSTPRG=cp
# This is probably irrelevant; this is the directory that the distribution
# shar-file will be placed. This is only of use to people re-distributing
# TEXTMASTER, after you've nuked your original copy of the shar file.
DISTDIR=/usr/src/DIST
# Set this to the extension your man pages use. On some systems, this
# would be "l" (as in L, not 1)
MANEXT=1
# Version number of program, to be used in distribution shell archive
# creation.
VER=14
# You should not need to change anything below this line.
all: tm
tm: tm.o convert.o
$(CC) $(CFLAGS) -o tm tm.o convert.o
tm.o: tm.c tm.h
$(CC) $(CFLAGS) -c tm.c
convert.o: convert.c tm.h
$(CC) $(CFLAGS) -c convert.c
install:
$(INSTPRG) tm $(BINDIR)/tm
$(INSTPRG) tm.1 $(MANDIR)/tm.$(MANEXT)
dist:
shar -cv README MANIFEST BUGS TODO Makefile tm.c \
tm.h convert.c tm.1 tm.hqx >tmp.sh
cat distinfo tmp.sh >$(DISTDIR)/tm$(VER).sh
/bin/rm -f tmp.sh
distmac:
shar -cv README MANIFEST BUGS TODO Makefile tm.c \
tm.h convert.c tm.1 >tmp.sh
cat distinfo tmp.sh >$(DISTDIR)/tm$(VER)mac.sh
/bin/rm -f tmp.sh
clean:
/bin/rm -f *.o tmp.sh
SHAR_EOF
if test 2304 -ne "`wc -c < 'Makefile'`"
then
echo shar: error transmitting "'Makefile'" '(should have been 2304 characters)'
fi
chmod +x 'Makefile'
fi # end of overwriting check
echo shar: extracting "'tm.c'" '(3810 characters)'
if test -f 'tm.c'
then
echo shar: will not over-write existing file "'tm.c'"
else
cat << \SHAR_EOF > 'tm.c'
/*************************************************************************
** **
** TM **
** TextMaster 1.4 **
** **
** By Donald Burr -- Copyright 1991 **
** **
** Released to the Public Domain **
** **
** Version History **
** **
** Date Version Comments **
** ---- ------- -------- **
** 10-Mar-91 1.0 Initial release. Written on a Mac **
** using LightSpeedC, and later uploaded **
** to UNIX, so can't say that it'll work **
** **
** 14-Mar-91 1.1 Ported to UNIX; discovered bug in usage **
** of hex notation. Fixed up screwy tabs. **
** **
** 14-Mar-91 1.2 Cleaned up some more code oddities, **
** split up the code into different files, **
** fixed a bug in the character xlation. **
** **
** 15-Mar-91 1.3 Cleaned up some more code; hacked up a **
** real kludgy Mac version; completed work **
** on the manpage; added the Mac version **
** (with its own documentation) to the **
** distribution as a BinHex (.hqx) file **
** **
** 09-May-91 1.4 Sent error messages to stderr. **
** Unified version numbers between both **
** Mac and UNIX versions. Changed name **
** of program to TextMaster. **
** **
*************************************************************************/
#include <stdio.h> /* Standard I/O functions */
#include "tm.h" /* defines for TextMaster */
main(argc, argv) /* main program */
int argc;
char *argv[]; /* command line arguments */
{
char the_input; /* input gathered from program */
int thing_to_do; /* tells us what func to perform */
char do_the_conversion(); /* this function does the stuff */
FILE *infile, *outfile, *fopen(); /* file handlers */
if (argc != 4) /* are we getting the right # of args? */
{
fprintf(stderr,
"\nTextMaster (tm) v1.4, (c)1991 Donald Burr\n");
fprintf(stderr,
"Usage: %s [um or mu] [inputfile or -] ", argv[0]);
fprintf(stderr, "[outputfile or -]\n", argv[0]);
fprintf(stderr, "\tum = UNIX -> Macintosh\n");
fprintf(stderr, "\tmu = Macintosh -> UNIX");
fprintf(stderr,
"\n\tinputfile = file to convert FROM, - for stdin\n");
fprintf(stderr,
"\toutputfile = file to convert TO, - for stdout\n");
fprintf(stderr, "\nReleased into the Public Domain\n\n");
exit(1);
}
/* Okay, we have the right args, so let's check if they're valid */
if (strcmp(argv[1], "um") == 0) /* are we doing unix->mac? */
thing_to_do = 1; /* 1 = convert unix->mac */
else if (strcmp(argv[1], "mu") == 0) /* are we doing mac->unix? */
thing_to_do = 2; /* 2 = convert mac->unix */
else /* assume invalid arg */
{
fprintf(stderr,
"\n%s: invalid parameter - <%s>\n", argv[0], argv[1]);
fprintf(stderr,
"Was expecting: mu = Mac -> UNIX translation\n");
fprintf(stderr,
" or: um = UNIX -> Mac translation\n\n");
fprintf(stderr, "Halt, cannot proceed.\n\n");
exit(1);
}
/* Assign filenames, or stdin/stdout if they are <-> */
if (strcmp(argv[2], "-") == 0) /* is input == stdin? */
infile = stdin; /* directly assign pointer */
else /* assume filename */
infile = fopen(argv[2], "r"); /* open the file specified */
if (strcmp(argv[3], "-") == 0) /* is output == stdout? */
outfile = stdout; /* directly assign pointer */
else /* assume filename */
outfile = fopen(argv[3], "w"); /* open for output */
/* Get input char-by-char */
while ((the_input = fgetc(infile)) != EOF)
/* while we've still got stuff */
fputc(do_the_conversion(the_input, thing_to_do), outfile);
/* Do the conversion */
}
SHAR_EOF
if test 3810 -ne "`wc -c < 'tm.c'`"
then
echo shar: error transmitting "'tm.c'" '(should have been 3810 characters)'
fi
chmod +x 'tm.c'
fi # end of overwriting check
echo shar: extracting "'tm.h'" '(830 characters)'
if test -f 'tm.h'
then
echo shar: will not over-write existing file "'tm.h'"
else
cat << \SHAR_EOF > 'tm.h'
/***************************************************************************
** **
** Special defines for TextMaster **
** **
***************************************************************************/
/* What #include file does your system use for strings? */
#include <string.h> /* OK for most SysV machines */
/* #include <strings.h> /* OK for most BSD machines */
/* #include <whatever.h> /* If none of above, find it! */
/* Defines for the charcters we'll be converting */
#define UNIX_EOL '\n' /* UNIX end-of-line character */
#define MAC_EOL 0x0d /* Mac end-of-line character */
/* That's it! */
SHAR_EOF
if test 830 -ne "`wc -c < 'tm.h'`"
then
echo shar: error transmitting "'tm.h'" '(should have been 830 characters)'
fi
chmod +x 'tm.h'
fi # end of overwriting check
echo shar: extracting "'convert.c'" '(971 characters)'
if test -f 'convert.c'
then
echo shar: will not over-write existing file "'convert.c'"
else
cat << \SHAR_EOF > 'convert.c'
/*************************************************************************
** **
** Char conversion routine for TextMaster **
** **
*************************************************************************/
#include <stdio.h> /* standard I/O functions */
#include "tm.h" /* Program-specific defines */
char do_the_conversion(inchar, thing_to_do)
char inchar;
int thing_to_do;
{
if (thing_to_do == 1) /* Doing UNIX -> Mac? */
{
if (inchar == UNIX_EOL) /* is it the Unix end? */
return(MAC_EOL); /* pass back Mac equiv. */
else
return(inchar); /* echo back the char */
}
else if (thing_to_do == 2) /* Doing Mac -> UNIX? */
{
if (inchar == MAC_EOL) /* is it the Mac end? */
return(UNIX_EOL); /* pass back UNIX equiv. */
else
return(inchar); /* echo back the char */
}
}
SHAR_EOF
if test 971 -ne "`wc -c < 'convert.c'`"
then
echo shar: error transmitting "'convert.c'" '(should have been 971 characters)'
fi
chmod +x 'convert.c'
fi # end of overwriting check
echo shar: extracting "'tm.1'" '(1525 characters)'
if test -f 'tm.1'
then
echo shar: will not over-write existing file "'tm.1'"
else
cat << \SHAR_EOF > 'tm.1'
.PU
.TH TM 1 "April 05, 1991" "UNIX User's Manual" "Donald Burr"
.SH NAME
tm \- convert text files between Mac and UNIX
.SH SYNOPSIS
.B tm
[mu/um] [inputfile or -] [outputfile or -]
.SH DESCRIPTION
.I tm
converts text files between UNIX and Macintosh formats. Since
each has its own separate carriage return/line feed conventions,
this is necessary.
.I tm
should be used ideally in a shell script
or alias, which calls a file transfer program (e.g.
.I xmodem
,
.I rz
,
.I sz
, etc.
.PP
.I tm
takes three (3) arguments. The first argument is the direction
indicator; it should be "mu" if you wish to convert from Mac to
UNIX, or "um" if you wish to convert from UNIX to Mac.
.PP
The second argument is the filename to take input from.
If a hyphen (-) is specified,
.I tm
will take input from stdin
(standard input). The third, and last, argument to
.I tm
,
consists of the filename to direct output to. If a hyphen
(-) is specified,
.I tm
will use standard output (stdout).
If the output file already exists, it will be overwritten.
If the input file doesn't exist,
.I tm
will most likely not work.
.PP
.SH "SEE ALSO
xmodem(1), rx(1), rb(1), rz(1), sx(1), sb(1), sz(1), kermit(1)
.SH AUTHOR
Donald Burr
.PP
.SH ADDRESSES
.SH INTERNET:
dburr@ocf.berkeley.edu, 72540.3071@compuserve.COM
.SH COMPU$ERVE:
72540,3071
.SH "AMERICA ONLINE:
DonaldBurr
.SH LIMITATIONS
.I tm
only works on one file at a time. It does not expand wildcards.
This is being worked on; the next version will probably include
this feature.
SHAR_EOF
if test 1525 -ne "`wc -c < 'tm.1'`"
then
echo shar: error transmitting "'tm.1'" '(should have been 1525 characters)'
fi
chmod +x 'tm.1'
fi # end of overwriting check
# End of shell archive
echo shar: end of shell archive.
exit 0